<?php
/**
 * NavigationMenu.php
 *
 * @author		b.wenneker <b.wenneker@gmail.com>, 2010
 */
class View_Helper_NavigationMenu extends Zend_View_Helper_Abstract{
	
	protected $_menuItems = array();
	
	public function addDefaultItems(){
		
		$this->addItem('Information about the application', '#', false, 'right small');
	}
	
	/**
	 * navigation() -
	 *
	 * @author b.wenneker <b.wenneker@gmail.com>, 2010
	 */
	public function navigationMenu(){
		
		// @todo [bw] clean up this mess.
		return <<<HTML
<ul id="menu">
	<li>Persoonlijk</li>
	<li class="active">Organisatie</li>
	<li>Zoek naar personen</li>
	
	<li class="right small"><a href="/unfuddle_bwab/public/common/auth/logout/">Afmelden</a></li>
	<li class="right small">Hulp bij het gebruiken van dit product</li>
</ul>
HTML;
	}
	
	public function addItem($label, $url, $active = false, $class = ''){
		$this->_menuItems[] = array(
			'label'		=> $label,
			'url' 		=> $url,
			'active'	=> $active,
			'class'	=> $class
		);
	}
	
	protected function _renderMenuItems(){
		
		$result		 = '';
		
		foreach((array)$this->_menuItems as $item){
			$result .= sprintf('<li class="%s"><a href="%s" title="%s">%s</a></li>',
				($item['active'] ? 'active ' : '') . $item['class'],
				$item['url'],
				$item['label'],
				$item['label']
			);
		}
		
		return $result;
	}
	
	/**
	 * __toString() - Converts this object to string.
	 *
	 * @author b.wenneker <b.wenneker@gmail.com>, 2010
	 */
	public function __toString(){
		$items	= $this->_renderMenuItems();
		
		return '<ul id="menu">'. $items .'</ul>';
	}
}